package com.hjz.login;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {


    LinearLayout mActivityMain;
    private Button qqBtn, weixinBtn;
    private SImageView mSImageView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        BarUtils.setTranslucent(this, 50);
        //px = dp*ppi/160
        LogUtils.e("-----------", ConvertUtils.px2dp(this, 56));
        LogUtils.e("------------", ConvertUtils.dp2px(this, 21));
        LogUtils.e("屏幕高度为：", ScreenUtils.getScreenHeight(this));
        LogUtils.e("屏幕宽度为：", ScreenUtils.getScreenWidth(this));
        LogUtils.e("网络用户：", NetworkUtils.getNetworkOperatorName(this));

        iniViews();
    }

    private void iniViews() {
        qqBtn = (Button) findViewById(R.id.qq_btn);
        weixinBtn = (Button) findViewById(R.id.weixin_btn);
        mSImageView= (SImageView) findViewById(R.id.siv_main);
        qqBtn.setOnClickListener(this);
        weixinBtn.setOnClickListener(this);
        mSImageView.setBorderColor(Color.RED);
        mSImageView.setBorderWidth(2);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.qq_btn:
                qqLogin();
                break;
            case R.id.weixin_btn:
                weixinLogin();
                break;
        }
    }

    private void qqLogin() {
        ToastUtils.showShortToast(this, "登陆成功");
    }

    private void weixinLogin() {
        if (LocationUtils.isGpsEnabled(this)) {
            ToastUtils.showShortToast(this, "GPS可用");
            LocationUtils.openGpsSettings(this);

        } else {
            ToastUtils.showShortToast(this, "GPS不可用");
        }

    }

}
